﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MvcApplication2.Models;

namespace MvcApplication2.Controllers
{
    public class HomeController : Controller
    {
        CDVEntities db=new CDVEntities();
        public ActionResult Index()
        {
            ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application.";
            THANHVIEN objthanhvien = new THANHVIEN();
            objthanhvien.TAI_KHOAN = "taikhoan";
            objthanhvien.MAT_KHAU = "12345";
            objthanhvien.NGAY_SINH = DateTime.Now;
            objthanhvien.HO = "dung";
            objthanhvien.TEN = "giau";
            objthanhvien.GIOI_TINH = true;
            objthanhvien.EMAIL = "dunghoang046@gmail.com";
            objthanhvien.LAN_DANG_NHAP_CUOI = DateTime.Now;
            objthanhvien.NGAY_THAM_GIA = DateTime.Now;
            db.THANHVIENs.Add(objthanhvien);
            db.SaveChanges();
            return View();
        }
        public string TaoMa()
        {
            string bangma = "ABCDEFGHIKLMLOPQRWZVabcdefghiklmnopqrwz01234567890";
            string ma = "";
            System.Random rd = new System.Random();
            for (int i = 0; i < 10; i++)
            {
                ma += bangma[rd.Next(50)];
            }
            return ma;
        }
        public ActionResult About()
        {
            ViewBag.Message = "Your app description page.";

            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }
    }
}
